/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.order.model;

import cn.ekuma.data.ui.swing.AbstractDTOTableModel;
import cn.ekuma.epos.businesslogic.OrderUtil;
import com.openbravo.format.Formats;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.bean.erp.OrderRelation;
import com.openbravo.bean.erp.viewbean.FindOrdersInfo;
/**
 *
 * @author Administrator
 */
@SuppressWarnings("serial")
public class OrderRelationTableModel extends AbstractDTOTableModel<OrderRelation> {

        public static String ORDERREFNOTES=AppLocal.getIntString("label.orderRefNotes");

		public Object getValueAt(int rowIndex, int columnIndex) {
            OrderRelation orderRelation=getObj(rowIndex);
            FindOrdersInfo orderInfo=orderRelation.getRelOrderInfo(); 
            switch(columnIndex){
            case 0:
                return orderInfo.getOrderId();
            case 1:
                return orderInfo.getDefineType();
            case 2:
                return orderInfo.getOrderType()==0?OrderUtil.ORDERTYPE_Normal:OrderUtil.ORDERTYPE_Revoerse;
            case 3:
                return Formats.TIMESTAMP.formatValue(orderInfo.getDate());
            case 4:
                return orderInfo.getCustomer()==null?"":orderInfo.getCustomer();
            case 5:
                 return orderInfo.getLocation();
            case 6:
                 return orderInfo.getName();
            case 7:
                  return Formats.CURRENCY.formatValue(orderInfo.getTotalPrice());
            case 8:
                  return orderInfo.getMemo();
            case 9:
                  return orderInfo.getCurrentState();
            case 10:
                  return orderInfo.getM_sResponse();
            case 11:
                  return orderInfo.getLocationRef1();
            case 12:
                  return Formats.PERCENT.formatValue(orderInfo.getM_dPriceRate());
            case 13:
          	       return Formats.CURRENCY.formatValue(orderInfo.getDebt());      
            case 14:
            	  return orderRelation.getMemo();
            case 15:
            	  return orderRelation.getAfterState();
            case 16:
          	      return Formats.CURRENCY.formatValue(orderRelation.getCash());	  
        }
			return null;
        }

	@Override
	public String[] getColumnNames() {
		return new String[]{
				AppLocal.getIntString("label.orderid"),
		        AppLocal.getIntString("label.ordertype"),
		        AppLocal.getIntString("label.ordertypedialog.bearing"),
		        AppLocal.getIntString("label.date"),
		        AppLocal.getIntString("label.customer"),
		        AppLocal.getIntString("label.location"),
		        AppLocal.getIntString("Menu.Users"),
		        AppLocal.getIntString("label.totalcash"),
		        AppLocal.getIntString("label.notes"),
		        AppLocal.getIntString("label.orderStates"),
		        AppLocal.getIntString("label.referncePerson"),
		        AppLocal.getIntString("label.address2"),
		        AppLocal.getIntString("label.priceRate"),
		        AppLocal.getIntString("label.curdebt"),
		        AppLocal.getIntString("label.orderRefNotes"),
			    AppLocal.getIntString("label.orderStates"),
			    AppLocal.getIntString("Label.Cash")
			    };
	}
 }
